<!-- 资料库 -->
<template>
	<view>
		<view class="list u-p-b-60">
			<view class="item"
				v-for="item in list"
				:key="item.id"
				@click="$Router.push({ path: '/pages/index/information/detail', query: { id: item.id } })">
				<view class="title">{{item.title}}</view>
				<view class="extra">
					<view>{{item.updatetime_text}}</view>
					<view class="u-flex u-col-center"
						style="color: #a8700d;">
						<view>提取素材</view>
						<text class="u-iconfont uicon-arrow-right u-m-l-10"
							style="color: #a8700d;font-size: 24rpx;"></text>
					</view>
				</view>
			</view>
			<view style="height: 20rpx;"></view>
			<!-- 更多 -->
			<u-loadmore v-show="!isEmpty"
				height="80rpx"
				:status="loadStatus"
				icon-type="flower"
				color="#ccc" />
			<!-- 空置页 -->
			<shopro-empty v-if="isEmpty"
				marginTop="300rpx"
				:image="$IMG_URL + '/imgs/empty/no_data.png'"
				tipText="暂无数据~"></shopro-empty>
		</view>
		<!-- #ifdef H5 -->
		<!-- <view class="tabbar-hack"
			style="height: 120rpx; width:100%;"></view> -->
		<!-- #endif -->
	</view>
</template>
<script>
	export default {
		components: {},
		data() {
			return {
				list: [],
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 1,
				lastPage: 1,
				isEmpty: false
			};
		},
		computed: {},
		filters: {
			applyInfoFilter: function(value) {
				if (!value) return '-';
				return Object.values(value).join(' | ');
			}
		},
		onLoad() {
			this.getList();
		},
		// 触底加载更多
		onReachBottom() {
			if (this.currentPage < this.lastPage) {
				this.currentPage += 1;
				this.getList();
			}
		},
		methods: {
			getList() {
				let that = this;
				that.loadStatus = 'loading';
				that.$http('information.list', {
					page: that.currentPage
				}).then(res => {
					if (res.code === 1) {
						that.list = [...that.list, ...res.data.data];
						that.isEmpty = !that.list.length;
						that.lastPage = res.data.last_page;
						that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
					}
				});
			}
		}
	};
</script>
<style lang="scss">
	.list {
		.item {
			padding: 30rpx;
			border-bottom: 1px solid #f7f7f7;
			background: #fff;

			.title {
				font-size: 32rpx;
			}

			.extra {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 20rpx;
				color: #828282
			}
		}
	}
</style>